Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADD][14.0] New module hr_holidays_validator_list #91

Closed

Conversation

victorvermot
Copy link

@victorvermot victorvermot commented Oct 4, 2023

A module making replacing the current leave_manager_id field by a many2many field called leave_manager_ids. Thus allowing a user to have several leave managers.

TODO:

  • More unit tests

@sarsurgithub sarsurgithub force-pushed the 14_hr_holidays_validator_list branch from b18b0e2 to d5920e7 Compare October 4, 2023 09:28
@victorvermot victorvermot force-pushed the 14_hr_holidays_validator_list branch from d5920e7 to 305e73d Compare October 4, 2023 09:37
@victorvermot victorvermot force-pushed the 14_hr_holidays_validator_list branch 5 times, most recently from 0bb47bc to e8ae591 Compare November 6, 2023 15:49
@victorvermot victorvermot force-pushed the 14_hr_holidays_validator_list branch 8 times, most recently from a1b2c1b to 1de1cdd Compare November 7, 2023 15:06
@victorvermot victorvermot force-pushed the 14_hr_holidays_validator_list branch from 1de1cdd to 7a177b5 Compare November 7, 2023 15:08
@victorvermot victorvermot marked this pull request as ready for review November 7, 2023 15:10
or Approver (determined in settings/users).""",
)

def _set_leave_manager_id_from_leave_manager_ids(self, values):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should have used a stored readable only computed method on leave_manager_id with a depends on leave_manager_ids to propagate any change.

Copy link
Author

@victorvermot victorvermot Nov 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right I am going to check that

Copy link
Member

@yvaucher yvaucher Nov 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@StephaneMangin The field leave_manager_ids is already a computed stored field. Question is can we insert nicely the set of the values from the M2M nicely or not. We might want to keep leave_manager_ids value to it's current natural computation.

@victorvermot

What we could probably do to improve the code is:

Override https://github.com/odoo/odoo/blob/17.0/addons/hr_holidays/models/hr_employee.py#L152-L159
this way:

    @api.depends('parent_id', 'leave_manager_ids')
    def _compute_leave_manager(self):
            
        for employee in self:
            if self.leave_manager_ids:
               self.leave_manager_id = leave_manager_ids[0]     
           else:
                super()._compute_leave_manager()

values["leave_manager_id"] = values["leave_manager_ids"][0][-1][-1]
return values

def _add_leave_manager_ids_in_group(self, values):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An onchange would have suffice to affect groups on managers.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree, we are on hr_employee, an onchange should only affect the values of the current form. Groups won't be available from here.

Copy link
Member

@yvaucher yvaucher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small typos and a proposal of improvement of the code.

hr_holidays_validator_list/models/hr_employee.py Outdated Show resolved Hide resolved
hr_holidays_validator_list/models/hr_leave_allocation.py Outdated Show resolved Hide resolved
values["leave_manager_id"] = values["leave_manager_ids"][0][-1][-1]
return values

def _add_leave_manager_ids_in_group(self, values):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree, we are on hr_employee, an onchange should only affect the values of the current form. Groups won't be available from here.

or Approver (determined in settings/users).""",
)

def _set_leave_manager_id_from_leave_manager_ids(self, values):
Copy link
Member

@yvaucher yvaucher Nov 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@StephaneMangin The field leave_manager_ids is already a computed stored field. Question is can we insert nicely the set of the values from the M2M nicely or not. We might want to keep leave_manager_ids value to it's current natural computation.

@victorvermot

What we could probably do to improve the code is:

Override https://github.com/odoo/odoo/blob/17.0/addons/hr_holidays/models/hr_employee.py#L152-L159
this way:

    @api.depends('parent_id', 'leave_manager_ids')
    def _compute_leave_manager(self):
            
        for employee in self:
            if self.leave_manager_ids:
               self.leave_manager_id = leave_manager_ids[0]     
           else:
                super()._compute_leave_manager()

Copy link

@cyrilmanuel cyrilmanuel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

… leave_manager_ids, for somecase that trigger unwanted fields update
@gurneyalex
Copy link
Member

@victorvermot you should check the CI: the tests are failing.

Copy link

github-actions bot commented Jun 2, 2024

There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days.
If you want this PR to never become stale, please ask a PSC member to apply the "no stale" label.

@github-actions github-actions bot added the stale PR/Issue without recent activity, it'll be soon closed automatically. label Jun 2, 2024
@github-actions github-actions bot closed this Jul 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved stale PR/Issue without recent activity, it'll be soon closed automatically.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants